package com.javaeye.chenweihuacwh.service.baseData;

import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.javaeye.chenweihuacwh.dao.baseData.LogisticsDAO;
import com.javaeye.chenweihuacwh.dao.baseData.ProductDAO;
import com.javaeye.chenweihuacwh.dto.baseData.Logistics;
import com.javaeye.chenweihuacwh.dto.baseData.Product;
import com.javaeye.chenweihuacwh.web.PageInfo;

public class LogisticsService implements ILogisticsService {
	
	private static Log log = LogFactory.getLog(ProductService.class);
	
	private LogisticsDAO dao;
	
	public void setDao(LogisticsDAO dao) {
		this.dao = dao;
	}

	@Override
	public Logistics getLogistics(String id) {
		int intId = Integer.parseInt(id);
		Logistics logistics = dao.getLogistics(intId);
		if (logistics == null) {
			log.warn("在数据库中未找到指定的产品  id：" + id);
		}
		return logistics;
	}

	@Override
	public List getLogisticsList(Logistics condition, PageInfo pageInfo) {
		pageInfo.setCount(dao.getAllCount(condition));
		List results = dao.getPageData(condition, pageInfo.getPageIndex(), pageInfo.getPageSize());
		if (results == null || results.size() == 0) {
			log.warn("在数据库中未找到产品数据");
		}
		return results;
	}

	@Override
	public void removeLogistics(String id) {
		int intId = Integer.parseInt(id);
		dao.removeLogistics(intId);
	}

	@Override
	public Logistics saveLogistics(Logistics logistics) {
		dao.saveLogistics(logistics);
		return logistics;
	}

}
